package toanstt.com.MatchUp;


import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.util.Log;
import android.view.MotionEvent;
import android.view.animation.AlphaAnimation;

public class Button 
{
	public Bitmap bitmap;
	public float scale=1.0f;
	
	public int x,y;
	int temp_x,temp_y;
	int action,actionCode ;
	public int anpla = 255;
	String string="";
	int str_x,str_y;
	int str_type;
	boolean isstring= false;
	public boolean isdisible = false;
	public boolean nottouch = false;
	public int minx,miny,maxx,maxy;
	public Button(Bitmap bitmap2,int x1,int y1)
	{
		bitmap = bitmap2;
		x = x1;
		y = y1;
		
		minx = x ;
		miny = y ;
		maxx = x + bitmap.getWidth();
		maxy = y + bitmap.getHeight();
	}
	public void SetAbletoTouch(boolean a)
	{
		nottouch = !a;
	}
	
	
	public void Draw(Canvas canvas)
	{
		//if(isdisible==true)
			//anpla = 80;
		//else
			//anpla = 255;
		//T.paint_alpha.setAlpha(anpla);
		//canvas.drawBitmap(bitmap, mat, T.paint_alpha);
		canvas.drawBitmap(bitmap, x, y,null);
	}
	
	public void Draw2(Canvas canvas)
	{
		
		T.paint_alpha.setAlpha(anpla);
		canvas.drawBitmap(bitmap, x, y,T.paint_alpha);
		
	
	}
	
	public boolean check_click(int x1,int y1)
	{
		if(isdisible==true)
			return false;
		anpla = 255;
		if(x1 > minx &&  x1 < maxx)
			if(y1 > miny &&  y1 < maxy)
			{
				anpla = 100;
				return true;
			}
		return false;
	}
	public boolean Kick(MotionEvent mo)
	{
		if(isdisible==true)
			return false;
		
		action = mo.getAction();
		actionCode = action & MotionEvent.ACTION_MASK;
		temp_x = (int)mo.getX();
		temp_y = (int)mo.getY();
		if(check_click(temp_x,temp_y)==true)
		{
			if(actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_MOVE)
			{
				anpla = 100;
				return false;
			}
			else if(actionCode == MotionEvent.ACTION_UP)
				return true;
		
		}
		return false;
	}
	public void SetString(String str)
	{
		string = str;
	}
	
}
